import API from '../../api/request'

// 用户每天登录奖励
export async function getAwardOneApi () {
	let isaward = await loadAward()
	if (isaward) return 
	let url = '/api/user/loginRewardEverday'
	let res = await API.post(url)
	if (res.code === '200') {
		saveAward()
		return res.data
	}
}

async function loadAward () {
	let award
	try {
		award = await global.storage.load({
			key: 'login.award'
		})
	} catch(e) {
		
	}
	return award
}

async function saveAward () {
	await global.storage.save({
		key: 'login.award',
		data: true
	})
}